package com.chuangjiangx.member.coupon.ddd.domain.model;

/**
 * 开关枚举
 *
 * @author wp
 * @date 2018-08-28 15:10
 **/
public enum  SwicthEnum {
    ON("开",1),
    OFF("关",0)
    ;

    public String name;
    public Integer code;

    SwicthEnum(String name, Integer code) {
        this.name = name;
        this.code = code;
    }

    public static SwicthEnum fromCode(Integer code){
        for(SwicthEnum swicthEnum:SwicthEnum.values()){
            if(code.equals(swicthEnum.code)){
                return swicthEnum;
            }
        }
        throw new IllegalStateException("不存在 该选项:  "+code);
    }
}
